home *** CD-ROM | disk | FTP | other *** search
- From: chase@centerline.com (David Chase)
- Message-ID: <4i9g94$4v4@wcap.centerline.com>
- X-Original-Date: 14 Mar 1996 16:08:04 GMT
- Path: in2.uu.net!bounce-back
- Date: 14 Mar 96 16:47:37 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Re: Exception handling -- was a finally block e
- Organization: CenterLine Software
- References: <31475017.8100207@nntp.ix.netcom.com>
- Reply-To: chase@centerline.com
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMUhNvOEDnX0m9pzZAQFchwF/QutqI7EdmbQDJsZAF0J084/VbzGl1DWT
- d1fv/YXbDEGtBIKJuL1EIN+qrnG22UcG
- =3rPY
-
- In article 8100207@nntp.ix.netcom.com, jdmorris@ix.netcom.com
- (Jason D. Morris) writes:
- > I would like to know if the following construct was ever considered by
- > the C++ and if it was, why it was rejected.
- > try
- > { }
- > catch ( // some expected exception type )
- > {}
- > finally
- > {
- > // code that would be guaranteed to execute no matter how the
- > // function was exited.
- > }
- >
- > Basically, a Java style finally clause. I also found it interesting
- > that Microsoft's structured exception handling under Win32 includes a
- > finally clause.
-
- Why, I'm not sure. One possibility might be that it was judged to be
- not necessary, because you can get the same effect in other ways.
-
- You can get the same effect if you wrap the try-catch up in a block that
- contains a local variable with an object type that does what you need.
- As in:
-
- {
- class fin {
- public:
- ~fin() {
- ...
- }
- fin( parameters ) {
- ...
- }
- };
-
- fin finally(parameters);
-
- try {} catch {}
-
- } // finally's destructor will be run here.
-
- This is not going to win any beauty contests, of course, but what
- did you expect?
-
- speaking for myself,
-
- David Chase
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-